
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
 * Bank.java
 *
 * Created on Jan 27, 2011, 11:36:23 PM
 */

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */
import javax.swing.*;
import java.sql.*;

final class Bank extends javax.swing.JInternalFrame {

PreparedStatement statement;
Systems systems=new Systems();
Thread bankThread=new Thread();
Thread bankTitleThread=new Thread();

    /** Creates new form TransactionType */
     Bank()
    {
        initComponents();
        resetCountry();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jAddressLabel = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jCountryComboBox = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jAddressTextArea = new javax.swing.JTextArea();
        jRegisterButton = new javax.swing.JButton();
        jNameTextField = new javax.swing.JTextField();
        jPhoneTextField = new javax.swing.JTextField();
        jZipTextField = new javax.swing.JTextField();
        jCityTextField = new javax.swing.JTextField();
        jStateTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jCancelButton = new javax.swing.JButton();

        setClosable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(Bank.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameIconified(evt);
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jAddressLabel.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jAddressLabel.setText(resourceMap.getString("jAddressLabel.text")); // NOI18N
        jAddressLabel.setName("jAddressLabel"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jCountryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        jCountryComboBox.setName("jCountryComboBox"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jAddressTextArea.setColumns(20);
        jAddressTextArea.setLineWrap(true);
        jAddressTextArea.setRows(5);
        jAddressTextArea.setName("jAddressTextArea"); // NOI18N
        jAddressTextArea.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jAddressTextAreaKeyTyped(evt);
            }
        });
        jScrollPane1.setViewportView(jAddressTextArea);

        jRegisterButton.setIcon(resourceMap.getIcon("jRegisterButton.icon")); // NOI18N
        jRegisterButton.setText(resourceMap.getString("jRegisterButton.text")); // NOI18N
        jRegisterButton.setName("jRegisterButton"); // NOI18N
        jRegisterButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRegisterButtonActionPerformed(evt);
            }
        });

        jNameTextField.setAutoscrolls(false);
        jNameTextField.setName("jNameTextField"); // NOI18N
        jNameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNameTextFieldActionPerformed(evt);
            }
        });
        jNameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jNameTextFieldKeyTyped(evt);
            }
        });

        jPhoneTextField.setText(resourceMap.getString("jPhoneTextField.text")); // NOI18N
        jPhoneTextField.setName("jPhoneTextField"); // NOI18N
        jPhoneTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jPhoneTextFieldKeyTyped(evt);
            }
        });

        jZipTextField.setName("jZipTextField"); // NOI18N
        jZipTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jZipTextFieldKeyTyped(evt);
            }
        });

        jCityTextField.setName("jCityTextField"); // NOI18N
        jCityTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jCityTextFieldKeyTyped(evt);
            }
        });

        jStateTextField.setName("jStateTextField"); // NOI18N
        jStateTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jStateTextFieldKeyTyped(evt);
            }
        });

        jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jCancelButton.setIcon(resourceMap.getIcon("jCancelButton.icon")); // NOI18N
        jCancelButton.setText(resourceMap.getString("jCancelButton.text")); // NOI18N
        jCancelButton.setName("jCancelButton"); // NOI18N
        jCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jAddressLabel)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jPhoneTextField)
                                    .addComponent(jScrollPane1)
                                    .addComponent(jNameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))))
                        .addGap(63, 63, 63)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jStateTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                            .addComponent(jCityTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                            .addComponent(jZipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCountryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 198, Short.MAX_VALUE)
                        .addComponent(jRegisterButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jCancelButton)
                        .addGap(63, 63, 63))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(52, 52, 52)
                                .addComponent(jAddressLabel))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jPhoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jCityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel7))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jStateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel6)
                                .addComponent(jCountryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(11, 11, 11)
                            .addComponent(jZipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jRegisterButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(59, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNameTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jNameTextFieldActionPerformed

    private void jRegisterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRegisterButtonActionPerformed
        // TODO add your handling code here:
        String value=jPhoneTextField.getText();
        int x=value.length();
        int y=0;
        char[] ch=value.toCharArray();

        
        if(jNameTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Bank's Name ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jAddressTextArea.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Bank's Address ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jPhoneTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Bank's Phone Number ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }

        while(y<x)
        {
        try
        {
            if(Character.isDigit(ch[y]))
            {

            }
            else
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Bank's Phone Number Must Be in Digits","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        catch(Exception e)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Phone Number Can Not Contain Alphabets","ERROR !",JOptionPane.ERROR_MESSAGE);
            jPhoneTextField.setText("");
            System.out.println(e+" Non int available in "+value+" non int is "+ch[y]);
            return;
        }
        y++;
        }
        
        if(jCityTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Bank's City ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jStateTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Bank's State ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jCountryComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Bank's Country ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        else{
            /* Execute submit thread */
            bankThread=new Thread(new Runnable() {
                public void run() {
                    disableControls();
                    submitData();
                    reset();
                }
            });
            bankTitleThread=new Thread(new Runnable() {
                public void run() {
                    while(bankThread.isAlive())setProcessingTitle(bankTitleThread);
                    enableControls();
                    System.out.println("accountThread stopped runing.");
                }
            });
            bankThread.start();
            bankTitleThread.start();
        }

        //JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Bank Registered Successfully ","Execution SUCCESSFUL !",JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jRegisterButtonActionPerformed
                               
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. New Bank - Processing Request");
            thread.sleep(500);
            this.setTitle("::. New Bank - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. New Bank - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. New Bank - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed
        
        if(bankThread.isAlive())
        {
            try{
                bankThread.stop();
                bankTitleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. New Bank");
            enableControls();
        }
        else
        this.dispose();
    }//GEN-LAST:event_jCancelButtonActionPerformed

    private void jNameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jNameTextFieldKeyTyped
        // TODO add your handling code here:
        String value=jNameTextField.getText();
        if(value.length()>39)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (40) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 39);
            jNameTextField.setText(newValue);
        }
    }//GEN-LAST:event_jNameTextFieldKeyTyped

    private void jCityTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jCityTextFieldKeyTyped
        // TODO add your handling code here:
        String value=jCityTextField.getText();
        if(value.length()>9)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (10) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 9);
            jCityTextField.setText(newValue);
        }
    }//GEN-LAST:event_jCityTextFieldKeyTyped

    private void jAddressTextAreaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jAddressTextAreaKeyTyped
        // TODO add your handling code here:
        String value=jAddressTextArea.getText();
        if(value.length()>79)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (80) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 79);
            jAddressTextArea.setText(newValue);
        }
    }//GEN-LAST:event_jAddressTextAreaKeyTyped

    private void jStateTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jStateTextFieldKeyTyped
        // TODO add your handling code here:
        String value=jStateTextField.getText();
        if(value.length()>9)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (10) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 9);
            jStateTextField.setText(newValue);
        }
    }//GEN-LAST:event_jStateTextFieldKeyTyped

    private void jPhoneTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPhoneTextFieldKeyTyped
        // TODO add your handling code here:
        String value=jPhoneTextField.getText();
        if(value.length()>14)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (15) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 14);
            jPhoneTextField.setText(newValue);
        }

    }//GEN-LAST:event_jPhoneTextFieldKeyTyped

    private void jZipTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jZipTextFieldKeyTyped
        // TODO add your handling code here:
        String value=jZipTextField.getText();
        if(value.length()>4)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (5) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 4);
            jZipTextField.setText(newValue);
        }

    }//GEN-LAST:event_jZipTextFieldKeyTyped

    private void formInternalFrameIconified(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameIconified
        // TODO add your handling code here:
        System.out.println("New Bank InterFrameIconified");
    }//GEN-LAST:event_formInternalFrameIconified

    public void submitData()
    {
        //Connect.createMSSQLConnection();
        Connect.changeDB(OpenMSApp.Database_A);
        statement=Connect.createStatement(Connect.procInit+" prnInsBank"+Connect.procInitStart+"?,?,?,?,?,?,?"+Connect.procInitEnd);
            try
            {
                statement.setString(1,jNameTextField.getText());
                statement.setString(2,jAddressTextArea.getText());
                statement.setString(3,jCityTextField.getText());
                statement.setString(4,jStateTextField.getText());
                statement.setString(5,String.valueOf(jCountryComboBox.getSelectedItem()));
                statement.setString(6,jZipTextField.getText());
                statement.setString(7,jPhoneTextField.getText());
            }
            catch(Exception e)
            {
                System.out.println("Bank.submitData() gave error ! "+e);
            }
        Connect.alert="Y";
        Connect.executeUpdateStatement(statement);
        Connect.closeConnection();
    }
     void resetCountry()
    {
        String[] country=systems.getTableDataArray(OpenMSApp.Database_A,"Country",2);
        country[0]="-- Select --";

        jCountryComboBox.setModel(new DefaultComboBoxModel(country));
        jCountryComboBox.setSelectedItem("NIGERIA");

    }
     void reset()
    {
        jNameTextField.setText("");
        jAddressTextArea.setText("");
        jCityTextField.setText("");
        jStateTextField.setText("");
        jZipTextField.setText("");
        jPhoneTextField.setText("");
        resetCountry();
    }
     void disableControls()
    {
        jNameTextField.setEditable(false);
        jNameTextField.setEnabled(false);
        
        jAddressTextArea.setEditable(false);
        jAddressTextArea.setEnabled(false);
        
        jCityTextField.setEditable(false);
        jCityTextField.setEnabled(false);
        
        jStateTextField.setEditable(false);
        jStateTextField.setEnabled(false);
        
        jZipTextField.setEditable(false);
        jZipTextField.setEnabled(false);
        
        jPhoneTextField.setEditable(false);
        jPhoneTextField.setEnabled(false);
        
        jCountryComboBox.setEnabled(false);
        
        jRegisterButton.setEnabled(false);
    }
     void enableControls()
    {
        jNameTextField.setEditable(true);
        jNameTextField.setEnabled(true);
        
        jAddressTextArea.setEditable(true);
        jAddressTextArea.setEnabled(true);
        
        jCityTextField.setEditable(true);
        jCityTextField.setEnabled(true);
        
        jStateTextField.setEditable(true);
        jStateTextField.setEnabled(true);
        
        jZipTextField.setEditable(true);
        jZipTextField.setEnabled(true);
        
        jPhoneTextField.setEditable(true);
        jPhoneTextField.setEnabled(true);
        
        jCountryComboBox.setEnabled(true);
        
        jRegisterButton.setEnabled(true);
        
        this.setTitle("::. New Bank");
    }
     void resetCombo()
    {
        resetCountry();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jAddressLabel;
    private javax.swing.JTextArea jAddressTextArea;
    private javax.swing.JButton jCancelButton;
    private javax.swing.JTextField jCityTextField;
    private javax.swing.JComboBox jCountryComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JTextField jNameTextField;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jPhoneTextField;
    private javax.swing.JButton jRegisterButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jStateTextField;
    private javax.swing.JTextField jZipTextField;
    // End of variables declaration//GEN-END:variables

}
